package com.kt.bit.bidw.bizmeta.controller;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kt.bit.bidw.bizmeta.service.AsisBizMetaInfoService;
import com.kt.bit.bidw.bizmeta.service.BizMetaInfoService;
import com.kt.bit.bidw.common.authority.SessionInfo;
import com.kt.bit.bidw.common.authority.SessionInfoSupport;
import com.kt.bit.bidw.meta.util.KTHashMap;
import com.kt.framework.controller.impl.KTControllerImpl;
import com.kt.framework.exception.BizException;

/**
 * AS-IS 비즈니스메타 정보 관리 Contol Class
 * <br/><b>History</b><br/>
 * <pre>
 * 2012. 5. 4. 최초작성
 * </pre>
 * @author cjsxowls
 * @version 1.0
 */
@Controller(value="asisBizMetaInfoController")
@RequestMapping(value="/asisBizMetaInfo.json")
public class AsisBizMetaInfoController extends KTControllerImpl {
	 
	private static final Log LOG = LogFactory.getLog(AsisBizMetaInfoController.class); 
	
	@Autowired
	private AsisBizMetaInfoService asisBizMetaInfoService;
	
	/**
	 * AS-IS 시스템 조회 <br>
	 * @param 
	 * @return List<Map<String, Object>>
	 */
	@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, params = "action=asIsSystemList")
	@ResponseBody
	public List<Map<String, Object>> asIsSystemList(
			final HttpServletRequest request) throws IOException { 
		final SessionInfo session = SessionInfoSupport.getSessionAttribute(request.getSession());
		if(session==null){
			throw new BizException("5001");
		}else{
			return asisBizMetaInfoService.asIsSystemList();
		}
	}
	
	/**
	 * AS-IS 비즈니스메타 Tree 조회 <br>
	 * @param KTHashMap<String, Object>
	 * @return List<Map<String, Object>>
	 */
	@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, params = "action=asIsObjBasTreeList")
	@ResponseBody
	public List<Map<String, Object>> asIsObjBasTreeList(
			final HttpServletRequest request,
			@RequestBody final KTHashMap<String, Object> params) throws IOException {
		final SessionInfo session = SessionInfoSupport.getSessionAttribute(request.getSession());
		if(session==null){
			throw new BizException("5001");
		}else{
			return asisBizMetaInfoService.asIsObjBasTreeList(params);
		}
	}
	
	/**
	 * TO-BE 비즈니스메타 Tree 조회 <br>
	 * @param KTHashMap<String, Object>
	 * @return List<Map<String, Object>>
	 */
	@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, params = "action=toBeObjBasTreeList")
	@ResponseBody
    public List<Map<String, Object>> toBeObjBasTreeList (
    		final HttpServletRequest request,
            @RequestBody final KTHashMap<String, Object> params) throws IOException {
		final SessionInfo session = SessionInfoSupport.getSessionAttribute(request.getSession());
		if(session==null){
			throw new BizException("5001");
		}else{
			return asisBizMetaInfoService.toBeObjBasTreeList(params);
		}
    }
	
	/**
	 * AS-IS 비즈니스메타 목록 조회 <br>
	 * @param KTHashMap<String, Object>
	 * @return List<Map<String, Object>>
	 */
	@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, params = "action=asIsObjBasGridList")
	@ResponseBody
	public List<Map<String, Object>> asIsObjBasGridList(
			final HttpServletRequest request,
			@RequestBody final KTHashMap<String, Object> params) throws IOException {
		final SessionInfo session = SessionInfoSupport.getSessionAttribute(request.getSession());
		if(session==null){
			throw new BizException("5001");
		}else{
			return asisBizMetaInfoService.asIsObjBasGridList(params);
		}
	}
	
	/**
	 * TO-BE 비즈니스메타 목록 조회 <br>
	 * @param KTHashMap<String, Object>
	 * @return List<Map<String, Object>>
	 */
	@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, params = "action=toBeObjBasGridList")
	@ResponseBody
    public List<Map<String, Object>> toBeObjBasGridList (
    		final HttpServletRequest request,
            @RequestBody final KTHashMap<String, Object> params) throws IOException {
		final SessionInfo session = SessionInfoSupport.getSessionAttribute(request.getSession());
		if(session==null){
			throw new BizException("5001");
		}else{
			return asisBizMetaInfoService.toBeObjBasGridList(params);
		}
    }
}